package cn.wegoteam.shop.polist;

import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

import cn.wegoteam.shop.po.Product;


public class JSONUtil {
	public static int paserJsonHouse(String jsonData,List<Product> list,StringBuilder sb){
		int total=0;
		try {
				JSONArray json = new JSONObject(jsonData).getJSONArray("Rows");
				for(int i = 0; i < json.length(); i++){
					Product product = new Product();
					JSONObject jsonObject = json.getJSONObject(i);
					product.setId(jsonObject.getInt("id"));
//					product.setName(jsonObject.getString("name"));
//					product.setImgUrl(jsonObject.getString("imgUrl"));
//					product.setPrice(Float.parseFloat(jsonObject.getString("price")));
//					product.setMarketPrice(Float.parseFloat(jsonObject.getString("marketPrice")));
					list.add(product);
					sb.append(product.getId()+",");
				}
			 total = new JSONObject(jsonData).getInt("Total");
		} catch (Exception e1) {
			System.out.println("json-------------"+jsonData);
			e1.printStackTrace();
		}
		return total;
	}
}
